package editor.windows;

import adventure.AdventureEdit;
import adventure.placeable.Mobile;
import adventure.placeable.MobileEdit;
import adventure.placeable.PlaceableManager;
import adventure.placeable.PlaceableManagerEdit;
import java.text.NumberFormat;

/**
 *
 * @author Michael Hanns
 * 
 */
public class DialogAddMobileView extends javax.swing.JDialog {

    private static final long serialVersionUID = -4650675120983439648L;
    private AdventureEdit adv;
    private PlaceableManager placeables;
    private int totalMobiles;
    int destX;
    int destY;
    int destZ;
    private WITNAFrameView parent;

    /**
     * Creates new form EditorItemView
     */
    public DialogAddMobileView(java.awt.Frame parent, AdventureEdit a,
            int x, int y, int z) {
        super(parent, true);
        this.parent = (WITNAFrameView) parent;
        adv = a;
        placeables = (PlaceableManager) adv.getPlaceableManager();
        destX = x;
        destY = y;
        destZ = z;
        initComponents();
        if (placeables.getMobile(1).getID() == 0) {
            ((PlaceableManagerEdit) placeables).newMobile();
        }
        fillTable();
        getMobileData(totalMobiles - 1);
    }

    public void fillTable() {
        mobileListTable.removeAll();

        int x = 1;
        while (placeables.getMobile(x).getID() != 0) {
            mobileListTable.getModel().setValueAt(placeables.getMobile(x).getID(), x - 1, 0);
            mobileListTable.getModel().setValueAt(((MobileEdit) placeables.getMobile(x)).getName(), x - 1, 1);
            x++;
        }

        totalMobiles = x;

        mobileListTable.changeSelection(x - 1, 2, false, false);
    }

    public void getMobileData(int row) {
        if (row > 0) {

            Mobile mob = placeables.getMobile(row);

            idBox.setText("" + mob.getID());
            nameBox.setText(((MobileEdit) mob).getAliveName());
            descriptionBox.setText(((MobileEdit) mob).getAliveDescription());
            levelBox.setText("" + mob.getLevel());
            attackBox.setText("" + mob.getAttack());
            defBox.setText("" + mob.getDefence());
            speedBox.setText("" + mob.getSpeed());
            luckBox.setText("" + mob.getLuck());
            hpBox.setText("" + mob.getMaxHealth());
            aggroBox.setSelected(mob.isAggro());
            lightSourceBox.setSelected(mob.isLightSource());
            visibleBox.setSelected(mob.isVisible());
            deadBox.setSelected(mob.isDead());
            immortalBox.setSelected(mob.isImmortal());
            vendorModBox.setText("" + mob.getVendorModifier());
            vendorBox.setSelected(mob.isVendor());
            aggroBox.setSelected(mob.isAggro());
            lightSourceBox.setSelected(mob.isLightSource());
            visibleBox.setSelected(mob.isVisible());
            goldBox.setText("" + mob.getCurrencyContents());

            inventoryList.removeAll();
            int x = 0;
            while (placeables.getMobile(row).getInventoryItem(x).getID() > 0) {
                x++;
            }
            String[] listData = new String[x];
            for (int y = 0; y < x; y++) {
                listData[y] = placeables.getMobile(row).getInventoryItem(y).getID()
                        + ":" + placeables.getMobile(row).getInventoryItem(y).getName();
            }
            inventoryList.setListData(listData);
        }
    }

    private void addMobile() {
        int id = Integer.parseInt(idBox.getText());
        String name = nameBox.getText();

        if (id > 0 && name.length() > 0) {

            adv.getRoomManager().addMobileToRoom(placeables.getMobile(id), destX, destY, destZ);
            parent.getRoomDetails(destX, destY, destZ);
            parent.printToConsole("Mobile " + name + " added to room "
                    + "(" + destX + "," + destY + "," + destZ + ").");

            if (adv.getRoomManager().getSpawnLevel(destX, destY, destZ) > 0) {
                boolean aggroMobs = false;
                int mobID = -1;
                for (int c = 0; (mobID = adv.getRoomManager().getMobileIDAtPosition(destX, destY, destZ, c)) != 0; c++) {
                    if (adv.getPlaceableManager().getMobile(mobID).isAggro()) {
                        aggroMobs = true;
                    }
                }
                if (aggroMobs) {
                    parent.printToConsole("WARNING: Aggro mobile at spawn position "
                            + "(" + destX + ", " + destY + ", " + destZ + "). It is advised that "
                            + "spawn locations remain safe.");
                }
            }

            parent.setUnsavedChanges(true);
        } else {
            parent.printToConsole("You must specify a name for the mobile before adding to a room!");
        }
        dispose();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        mobileListPane = new javax.swing.JScrollPane();
        mobileListTable = new javax.swing.JTable();
        nameBox = new javax.swing.JFormattedTextField();
        idBox = new javax.swing.JFormattedTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        descriptionBox = new javax.swing.JTextPane();
        idLabel = new javax.swing.JLabel();
        nameLabel = new javax.swing.JLabel();
        descriptionLabel = new javax.swing.JLabel();
        closeButton = new javax.swing.JButton();
        addButton = new javax.swing.JButton();
        statusPanel1 = new javax.swing.JPanel();
        vendorBox = new javax.swing.JCheckBox();
        visibleBox = new javax.swing.JCheckBox();
        lightSourceBox = new javax.swing.JCheckBox();
        deadBox = new javax.swing.JCheckBox();
        aggroBox = new javax.swing.JCheckBox();
        immortalBox = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        levelLabel3 = new javax.swing.JLabel();
        attackBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        totalUsesLabel3 = new javax.swing.JLabel();
        levelLabel4 = new javax.swing.JLabel();
        totalUsesLabel4 = new javax.swing.JLabel();
        levelBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        hpBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        totalUsesLabel5 = new javax.swing.JLabel();
        defBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        speedBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        levelLabel5 = new javax.swing.JLabel();
        luckBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        inventoryPanel = new javax.swing.JPanel();
        inventoryLabel = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        inventoryList = new javax.swing.JList();
        goldLabel = new javax.swing.JLabel();
        goldBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        vendorModLabel = new javax.swing.JLabel();
        vendorModBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane2.setViewportView(jList1);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Add Mobile");
        setAlwaysOnTop(true);
        setLocationByPlatform(true);
        setResizable(false);

        mobileListTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "#", "Name"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        mobileListTable.setToolTipText("Mobile list");
        mobileListTable.setColumnSelectionAllowed(true);
        mobileListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        mobileListTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mobileListTableMouseClicked(evt);
            }
        });
        mobileListPane.setViewportView(mobileListTable);
        mobileListTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        mobileListTable.getColumnModel().getColumn(0).setMinWidth(10);
        mobileListTable.getColumnModel().getColumn(0).setPreferredWidth(25);
        mobileListTable.getColumnModel().getColumn(0).setMaxWidth(25);

        nameBox.setEditable(false);
        nameBox.setToolTipText("Item name");

        idBox.setEditable(false);
        idBox.setToolTipText("Item number");

        descriptionBox.setEditable(false);
        descriptionBox.setToolTipText("Item description");
        descriptionBox.setEnabled(false);
        jScrollPane1.setViewportView(descriptionBox);

        idLabel.setText("ID:");

        nameLabel.setText("Name:");

        descriptionLabel.setText("Description:");

        closeButton.setText("Close");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        addButton.setText("Add to (" + destX + "," + destY + "," + destZ+")");
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });

        statusPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Status:"));

        vendorBox.setText("Vendor");
        vendorBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vendorBoxActionPerformed(evt);
            }
        });

        visibleBox.setText("Visible");
        visibleBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visibleBoxActionPerformed(evt);
            }
        });

        lightSourceBox.setText("Light Source");

        deadBox.setText("Dead");
        deadBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deadBoxActionPerformed(evt);
            }
        });
        deadBox.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                deadBoxPropertyChange(evt);
            }
        });

        aggroBox.setText("Aggro");
        aggroBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aggroBoxActionPerformed(evt);
            }
        });

        immortalBox.setText("Immortal");
        immortalBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                immortalBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout statusPanel1Layout = new javax.swing.GroupLayout(statusPanel1);
        statusPanel1.setLayout(statusPanel1Layout);
        statusPanel1Layout.setHorizontalGroup(
            statusPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statusPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(visibleBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lightSourceBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(aggroBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(vendorBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(immortalBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(deadBox, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        statusPanel1Layout.setVerticalGroup(
            statusPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanel1Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(statusPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(immortalBox)
                    .addComponent(visibleBox))
                .addGap(6, 6, 6)
                .addGroup(statusPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(deadBox)
                    .addComponent(lightSourceBox))
                .addGap(6, 6, 6)
                .addGroup(statusPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vendorBox)
                    .addComponent(aggroBox))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Statistics:"));

        levelLabel3.setText("Attack:");

        attackBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        totalUsesLabel3.setText("Defence:");

        levelLabel4.setText("Level:");

        totalUsesLabel4.setText("Health:");

        levelBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        hpBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        totalUsesLabel5.setText("Luck:");

        defBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        speedBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        levelLabel5.setText("Speed:");

        luckBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(levelLabel3)
                    .addComponent(levelLabel4)
                    .addComponent(totalUsesLabel3))
                .addGap(5, 5, 5)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(levelBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)
                    .addComponent(attackBox, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(defBox))
                .addGap(12, 12, 12)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(totalUsesLabel5)
                    .addComponent(levelLabel5)
                    .addComponent(totalUsesLabel4, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(hpBox, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)
                    .addComponent(speedBox)
                    .addComponent(luckBox, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(10, 10, 10))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(levelLabel4)
                    .addComponent(levelBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(totalUsesLabel4)
                    .addComponent(hpBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(attackBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(levelLabel3)
                    .addComponent(levelLabel5)
                    .addComponent(luckBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(speedBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(totalUsesLabel3)
                        .addComponent(defBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(totalUsesLabel5)))
                .addGap(0, 10, Short.MAX_VALUE))
        );

        inventoryPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Inventory:"));

        inventoryLabel.setText("Items:");

        jScrollPane3.setViewportView(inventoryList);

        goldLabel.setText("Currency:");

        goldBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        vendorModLabel.setText("Profit %:");
        vendorModLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        vendorModBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        javax.swing.GroupLayout inventoryPanelLayout = new javax.swing.GroupLayout(inventoryPanel);
        inventoryPanel.setLayout(inventoryPanelLayout);
        inventoryPanelLayout.setHorizontalGroup(
            inventoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inventoryPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(inventoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3)
                    .addGroup(inventoryPanelLayout.createSequentialGroup()
                        .addComponent(inventoryLabel)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(16, 16, 16)
                .addGroup(inventoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(goldLabel)
                    .addComponent(vendorModLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(inventoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(vendorModBox, javax.swing.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)
                    .addComponent(goldBox))
                .addContainerGap())
        );
        inventoryPanelLayout.setVerticalGroup(
            inventoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inventoryPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(inventoryLabel)
                .addGap(6, 6, 6)
                .addGroup(inventoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(inventoryPanelLayout.createSequentialGroup()
                        .addGroup(inventoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(goldLabel)
                            .addComponent(goldBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addGroup(inventoryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(vendorModLabel)
                            .addComponent(vendorModBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mobileListPane, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(idLabel)
                            .addComponent(idBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(8, 8, 8)
                                .addComponent(nameLabel))
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(nameBox))))
                    .addComponent(jScrollPane1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(descriptionLabel)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(inventoryPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(statusPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(closeButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(addButton, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(mobileListPane, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(idLabel)
                            .addComponent(nameLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nameBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(idBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(descriptionLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(statusPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(inventoryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(addButton)
                            .addComponent(closeButton))))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

	private void mobileListTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mobileListTableMouseClicked
            int row = mobileListTable.getSelectedRow();

            if (row > -1) {
                int id = Integer.parseInt(mobileListTable.getModel().getValueAt(row, 0).toString());
                getMobileData(id);
            }
	}//GEN-LAST:event_mobileListTableMouseClicked

	private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
            dispose();
	}//GEN-LAST:event_closeButtonActionPerformed

	private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
            addMobile();
	}//GEN-LAST:event_addButtonActionPerformed

    private void vendorBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vendorBoxActionPerformed

    }//GEN-LAST:event_vendorBoxActionPerformed

    private void visibleBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visibleBoxActionPerformed

    }//GEN-LAST:event_visibleBoxActionPerformed

    private void deadBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deadBoxActionPerformed

    }//GEN-LAST:event_deadBoxActionPerformed

    private void deadBoxPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_deadBoxPropertyChange

    }//GEN-LAST:event_deadBoxPropertyChange

    private void aggroBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aggroBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_aggroBoxActionPerformed

    private void immortalBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_immortalBoxActionPerformed

    }//GEN-LAST:event_immortalBoxActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addButton;
    private javax.swing.JCheckBox aggroBox;
    private javax.swing.JFormattedTextField attackBox;
    private javax.swing.JButton closeButton;
    private javax.swing.JCheckBox deadBox;
    private javax.swing.JFormattedTextField defBox;
    private javax.swing.JTextPane descriptionBox;
    private javax.swing.JLabel descriptionLabel;
    private javax.swing.JFormattedTextField goldBox;
    private javax.swing.JLabel goldLabel;
    private javax.swing.JFormattedTextField hpBox;
    private javax.swing.JFormattedTextField idBox;
    private javax.swing.JLabel idLabel;
    private javax.swing.JCheckBox immortalBox;
    private javax.swing.JLabel inventoryLabel;
    private javax.swing.JList inventoryList;
    private javax.swing.JPanel inventoryPanel;
    private javax.swing.JList jList1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JFormattedTextField levelBox;
    private javax.swing.JLabel levelLabel3;
    private javax.swing.JLabel levelLabel4;
    private javax.swing.JLabel levelLabel5;
    private javax.swing.JCheckBox lightSourceBox;
    private javax.swing.JFormattedTextField luckBox;
    private javax.swing.JScrollPane mobileListPane;
    private javax.swing.JTable mobileListTable;
    private javax.swing.JFormattedTextField nameBox;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JFormattedTextField speedBox;
    private javax.swing.JPanel statusPanel1;
    private javax.swing.JLabel totalUsesLabel3;
    private javax.swing.JLabel totalUsesLabel4;
    private javax.swing.JLabel totalUsesLabel5;
    private javax.swing.JCheckBox vendorBox;
    private javax.swing.JFormattedTextField vendorModBox;
    private javax.swing.JLabel vendorModLabel;
    private javax.swing.JCheckBox visibleBox;
    // End of variables declaration//GEN-END:variables
}
